#include "Common/Common.h"
#include "EditorCore/Traversers/SimpleEntityTraverser.h"

using namespace cmn;

namespace editor_core {

	void SimpleEntityTraverser::InnerTraverse( IEntity* entity, IEntityVisitor* visitor, std::set<int>& visitedEntities ) {
		if( visitedEntities.find( entity->GetId() ) != visitedEntities.end() )
			return;

		visitor->VisitEntity( entity );
		visitedEntities.insert( entity->GetId() );

		Vector<IEntity*> children;
		entity->GetChildren( children );

		for( IteratorPtr<IEntity*> childrenIter( children );
				!childrenIter.IsEnd();
				childrenIter.Next() )
		{
			IEntity* child = childrenIter.Current();
			InnerTraverse( child, visitor, visitedEntities );
		}
	}

}
